package Lotr.game;

import Lotr.game.Entity.Player;
import Lotr.game.Entity.Spell;
import Lotr.game.Entity.SpellTypes.FreezeSpell;
import Lotr.game.Entity.TowerTypes.BasicTower;
import Lotr.game.GUI.MainFrame;
import java.awt.Graphics;
import java.awt.Point;
import java.io.IOException;

/*
 * Controls all object needed for the game Everything the "Game" object needs,
 * does it get here!
 *
 */
public class GameManager {

    private Level level;
    private Game game;
    private Player player;
    private int width, height;
    private Resources res;
    
    //TODO: remove
    private MainFrame mf;
    private Spell s;
    private BasicTower bt;

    public void setMF(MainFrame mf) {
        this.mf = mf;
    }

    public GameManager(int width, int height, Game game) throws IOException {
        this.width = width;
        this.height = height;
        this.game = game;
        res = new Resources();
        s = new FreezeSpell(this);
        bt = new BasicTower(0,this);
        player = new Player();
        level = new Level(width, height, res, this);
    }

    public void render(Graphics g) {
        level.render(g);
        s.render(g);
        bt.render(g);
    }

    public void update() {
        level.update();
        s.update();
        bt.update();
        mf.setHealtProgress(player.getHealth());
    }

    public Resources getResources() {
        return res;
    }

    public Point getMousePosition() {
        return game.getMousePosition();
    }

    public void hotKey1() {
        s.spellChosen();
    }
    
    public void hotKey2() {
        bt.chosen();   
    }

    public void mouseReleased() {
        s.spellCasted();
        bt.place();
    }

    public Player getPlayer() {
        return player;
    }
}
